<?php 
get_header();
$laiyuan = trim(urldecode(get_query_var('laiyuan')));
$authid = get_the_author_meta( 'ID' );
$images = get_avatar( $authid,100 );
$name = $laiyuan?$laiyuan:get_the_author_meta('display_name');
$uviews = (get_user_meta( $authid, 'uviews',true))?(get_user_meta( $authid, 'uviews',true)):0;
$zzan = (get_user_meta( $authid, 'zzan',true))?(get_user_meta( $authid, 'zzan',true)):0;
$comments_count = get_comments( array('status' => '1', 'user_id'=>$authid, 'count' => true) );
$authemail = get_the_author_meta( 'email' );
if($laiyuan){
	$args = array(
	'ignore_sticky_posts' => 1,
    'paged' => $paged,
    'meta_key'=>'laiyuan_value',
    'meta_value'=>$laiyuan
	);
	query_posts($args);
}
?>
<style>@media screen and (max-width:767px){.container .row {margin-right: -25px;margin-left: -25px;}}</style>
<div id="author-bg-wrap">
<div class="author-bg" style="background-image:url(<?php bloginfo('template_directory'); ?>/img/authorbg.png)">
	<div class="author-info">
		<div class="avatar">
			<?php echo $images;?>
		</div>
		<div class="name">
			<span class="author-name">
                <?php echo $name ?>                      
			</span>
		</div>
		<div class="dec">
			<?php if(get_the_author_meta('description')){ echo the_author_meta( 'description' );}else{echo'我还没有学会写个人说明！'; }?>
		</div>
			<div class="options">
				<a rel="nofollow" target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=<?php echo $authemail;?>" class="btn btn-normal orange btn-bordered" >私信</a>			
			</div>

	</div>	
	<div class="zuozhebg2">
	<div class="author-nav">
		<ul>
			<li class="postlist current"><?php echo $found_posts; ?>文章(<?php if($laiyuan){echo $wp_query->found_posts;}else{echo count_user_posts( $authid );}?>)</li>
			<!-- <li class="commentlist">评论(<?php echo $comments_count;?>)</li> -->
		</ul>
	</div>
	</div>
</div>
</div>
<div class="author-content">
	<div class="content-box">
		<div class="container">
			<div class="row">
			<div class="col-sm-12 col-md-8 col-lg-8 cont-left">

				<div class="author-posts mod-article-list">
					<ul class="clearfix d_author feed-infinite-wrapper">
						<?php 
						if (have_posts()) :while ( have_posts() ) : the_post();?>
						<li class="article-item clearfix">
						<div class="image">
							<a href="<?php the_permalink();?>">
					<?php if (ztmao('qiniu') == '1') { ?>    
					<?php wpjam_post_thumbnail(array(220,165),$crop=1);?>    
					<?php } else { } ?>    
					<?php if (ztmao('qiniu') == '0') { ?>    
					<img class="xyscale" src="<?php echo get_template_directory_uri(); ?>/timthumb.php?src=<?php echo post_thumbnail_src(); ?>&w=220&h=165&zc=1" alt="<?php the_title(); ?>"/> 
					<?php } else { } ?> 
							</a>
						</div>
						<div class="info">
							<div class="title">
								<a href="<?php the_permalink();?>"><?php the_title();?></a>
							</div>
							<div class="dec">
								<?php echo mb_strimwidth( strip_tags( apply_filters( 'the_content', $post->post_content ) ), 0, 130,"..." ); ?>
							</div>
							<div class="mob-author">
								<span class="time"><i class="iconfont icon-shijian"></i> <?php echo timeago( get_gmt_from_date(get_the_time('Y-m-d G:i:s')) ); ?></span>
							</div>
						</div>
						</li>
						<?php endwhile;endif; ?>
					</ul>
					<!-- <div id="page"><?php par_pagenavi(5); ?></div> -->
					<div class="get-mod-more js-get-mod-more-list transition" style="display: none;">
			 		<?php {
					next_posts_link('点击加载更多','');
					}?>	
					</div>
					<div class="scroller-status" style="display: none;">
					  <div class="infinite-scroll-request loader-ellips loading ball-pulse"><div></div> <div></div> <div></div> <span>加载中⋅⋅⋅</span></div>
					  <p class="infinite-scroll-last transition">沒有更多了...</p>
					  <p class="infinite-scroll-error transition">加载失败...</p>
					</div>
				</div>
		
		
				<div class="user-state comment-article-list clear" style="display: none;">
					<?php
						$paged = max( 1, get_query_var('page') );
						$number = get_option(1,10);
						$offset = ($paged-1)*$number;
						$approve = get_comments( array('status' => '1', 'user_id'=>$authid, 'count' => true) );
						$pages = ceil($approve/$number);
						$comments = get_comments(array('status' => 'approve','order' => 'DESC','number' => $number,'offset' => $offset,'user_id' => $authid));
						if($comments){
					?>
					<div class="top-circle"><div class="circle-b"><span class="circle-c"></span></div></div><ul class="state-list">
					<?php foreach( $comments as $comment ){?>
						<li>
							<div class="l-cont">
								<time><?php echo $comment->comment_date;?></time>
								<span class="point"></span>
							</div>
							<div class="r-cont">
								<div class="inner">
									<p class="head-line">发表在：</p>
									<p class="title"><a href="<?php echo get_comment_link( $comment->comment_ID);?>" target="_blank"><?php echo get_the_title($comment->comment_post_ID);?></a></p>
									<p class="intro"><?php comment_text($comment->comment_ID);?></p>
								</div>
							</div>
						</li>
					<?php }?>
					</ul>	
					<?php }else{?>
					<p style="text-align: center;font-size: 1.6rem;color: #333333;margin-bottom: 12px;">暂无评论</p>		
					<?php }?>			
					<div id="loading-comments" style="margin-top: -23px;"><span> 加载中...</span></div>
		            <?php echo ztmao_pager($paged, $pages);?>
	        	</div>
		
			</div>
			<?php get_sidebar(); ?>
			</div>
		</div>
		
	</div>
</div>
<?php get_footer('author');?>